import com.aaa.dao.xg.ResultDivDao;
import com.aaa.dao.xg.TesterFpaDao;
import com.aaa.dao.xg.ViewResultDao;
import com.aaa.pojo.*;

import com.aaa.service.sys.DeptService;
import com.aaa.service.sys.ViewTestPlanService;
import com.aaa.service.xg.PlanFpaService;
import com.aaa.service.xg.QuFpaService;
import com.aaa.service.xg.QuSasService;

import com.aaa.service.yy.QuSdsService;
import lombok.ToString;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class test {

    @Autowired
    private QuFpaService qu_fpaService;

    /*@Test
    public void test(){
        List<QuFpa> all = qu_fpaService.findAll(0,3);
        System.out.println(all);
    }*/
    @Test
    public void test2(){
        int count = qu_fpaService.findCount();
        System.out.println(count);
    }

    /*@Test
    public void test3(){
        List<QuFpa> all1 = qu_fpaService.findAll1();
        System.out.println(all1);
    }*/

    @Autowired
    private PlanFpaService planFpaService;
    @Test
    public void test4(){
        List<PlanFpa> all = planFpaService.findAll("0","1");
        System.out.println(all);
    }

    @Test
    public void test5(){
        QuFpa quFpa = new QuFpa();
        quFpa.setQuestion("你现在快乐吗？");
        quFpa.setOptionA("我很快乐");
        quFpa.setOptionB("我比较快乐");
        quFpa.setOptionC("我不快乐");
        quFpa.setOptionD("我很不快乐");
        quFpa.setType(1);
        quFpa.setStatus(0);
        quFpa.setCreateTime(new Date());
        quFpa.setCreateBy("admin");

        int insert = qu_fpaService.insert(quFpa);
        System.out.println(insert);
    }

    @Test
    public void test6(){
        QuFpa quFpa = new QuFpa();
        quFpa.setUpdateBy("admin");
        quFpa.setUpdateTime(new Date());
        quFpa.setCreateBy("admin");
        quFpa.setCreateTime(new Date());
        quFpa.setId(39);
        int update = qu_fpaService.update(quFpa);
        System.out.println(update);
    }

   /* @Test
    public void delete(){
        int delete = qu_fpaService.delete(37);
        System.out.println(delete);
    }*/

   /* @Test
    public void delete(){
        ArrayList<Integer> objects = new ArrayList<Integer>();
        objects.add(34);
        objects.add(35);
        int delete = qu_fpaService.delete(objects);
        System.out.println(delete);

    }*/

   /* @Test
    public void test(){
        List<QuFpa> quFpaList = qu_fpaService.findByQuestionAndName("我", null);
        System.out.println(quFpaList);
    }
*/

    /*@Test
    public void test7(){
        PlanFpa planFpa = new PlanFpa();
        planFpa.setTestName("asdf");
        planFpa.setTestBegin(new Date());
        planFpa.setTestEnd(new Date());
        planFpa.setRemark("planpfa");
        int insert = planFpaService.insert(planFpa);
        System.out.println(insert);
    }*/

    @Test
    public void update(){
        PlanFpa planFpa = new PlanFpa();
        planFpa.setTestName("aaa");
        planFpa.setId(10);
        int update = planFpaService.update(planFpa);
        System.out.println(update);
    }

    @Test
    public void find(){
        List<PlanFpa> qy = planFpaService.findByName("qy", null);
        System.out.println(qy);
    }

    @Autowired
    private TesterFpaDao testerFpaDao;
    @Test
    public void test (){
        List<TesterFpa> all = testerFpaDao.findAll();
        for (TesterFpa tester : all) {
            System.out.println(tester);
        }

    }
    @Autowired
    private ViewResultDao viewResultDao;

    /*@Test
    public void view (){
        List<ViewResultFpa> all = viewResultDao.findAll();
        System.out.println(all);

    }*/

    @Test
    public void testView(){
        ViewResultFpa byId = viewResultDao.findById(3);
        System.out.println(byId);
    }
    @Test
    public void testGroup (){

        System.out.println(viewResultDao.findCountPlanId());

    }
   /* @Test
    public void testIf(){
        System.out.println(viewResultDao.findIf(null,1));
    }*/
    @Autowired
    private ResultDivDao resultDivDao;
    @Test
    public void testResult(){
        List<ResultDiv> all = resultDivDao.findAll();
        System.out.println(all);
    }
    @Test
    public void findCount(){
        int a = qu_fpaService.findIfCount("我的", null);
        System.out.println(a);
    }

    @Autowired
    private DeptService deptService;

   /* @Test
    public void deptTest1(){
        for (Dept dept2 : deptService.findAll()) {
            System.out.println(dept2);
        }

    }*/
    @Test
    public void deptTest2(){
        int count = deptService.findCount();
        System.out.println(count);
    }

    /*@Test
    public void deptTest3(){
        Dept dept = new Dept();
        dept.setDeptName("bbb");
        dept.setOrderNum(5);
        dept.setStatus("0");
        dept.setCreateTime(new Date());
        int insert = deptService.insert(dept);
        System.out.println(insert);
    }*/

    @Test
    public void deptTest4(){
        ArrayList<String> strings = new ArrayList<>();
        strings.add("217");
        int delete = deptService.delete(strings);
        System.out.println(delete);
    }

    @Autowired
    private ViewTestPlanService viewTestPlanService;
    @Test
    public void findTestCode(){
        ViewTestPlan byTestCode = viewTestPlanService.findByTestCode(123458);
        System.out.println(byTestCode);
    }

    @Test
    public void findAll(){
        List<QuFpa> allQuestion = qu_fpaService.findAllQuestion();

        System.out.println(allQuestion);
    }
   /* @Autowired
    private QuSdsService quSdsService;
    @Test
    public void testFind(){
        List<QuSds> allQuestion = quSdsService.findAllQuestion();
        System.out.println(allQuestion);
    }*/

    @Autowired
    private QuSasService quSasService;
    @Test
    public void testAll(){
        for (QuSas quSas : quSasService.findAllQuestion()) {
            System.out.println(quSas);
        }

    }
}
